﻿namespace dPet.Domain.Bootstrapper
{
	using dPet.Domain.Events;
	using dPet.Domain.Events.Handlers;
	using dPet.Domain.Services;
	using dPet.Domain.Services.Implementation;
	using Hangerd.Bootstrapper;
	using Hangerd.Event;
	using Hangerd.Extensions;
	using Microsoft.Practices.Unity;

	public class RegisterServiceTask : RegisterServiceBootstrapperTask
	{
		public RegisterServiceTask(IUnityContainer container) : base(container) { }

		public override void Execute()
		{
			//domain services
			_container.RegisterTypeAsPerResolve<IAccountDomainService, AccountDomainService>();
			_container.RegisterTypeAsPerResolve<IInvoicingDomainService, InvoicingDomainService>();
			_container.RegisterTypeAsPerResolve<IServingDomainService, ServingDomainService>();

			//domain events
			_container.RegisterMultipleTypesAsPerResolve<IDomainEventHandler<InventoryReducedEvent>, InventoryReducedEventHandler>();
			_container.RegisterMultipleTypesAsPerResolve<IDomainEventHandler<InventoryLOReportedEvent>, InventoryLOReportedEventHandler>();
			_container.RegisterMultipleTypesAsPerResolve<IDomainEventHandler<SaleOrderCanceledEvent>, SaleOrderCanceledEventHandler>();
			_container.RegisterMultipleTypesAsPerResolve<IDomainEventHandler<InventoryAlarmDisabledEvent>, InventoryAlarmDisabledEventHandler>();
			_container.RegisterMultipleTypesAsPerResolve<IDomainEventHandler<InventoryCheckedEvent>, InventoryCheckedEventHandler>();
		}
	}
}
